home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 November
/
EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso
/
earcd
/
util
/
cli
/
nvtools.lha
/
SetNV.mod
< prev
next >
Wrap
Text File
|
1995-09-30
|
2KB
|
82 lines
MODULE SetNV;
(*
$StackChk-
$RangeChk-
$NilChk-
$OvflChk-
$ReturnChk-
$CaseChk-
*)
IMPORT
y := SYSTEM,
(* Interfaces *)
d := Dos,
e := Exec,
nv := NonVolatile,
str := Strings;
CONST
template = "AN=APPNAME/A,IN=ITEMNAME/A,KR=KILLREQUESTER/S,DATA/A/F"
"\o$VER: SetNV.mod 1.0 (30.09.95)";
TYPE
Args = STRUCT (as :d.ArgsStruct)
appName :d.ArgString;
itemName :d.ArgString;
killReq :d.ArgBool;
data :d.ArgString;
END;
VAR
args :d.RDArgsPtr;
argv :Args;
size :LONGINT;
info :nv.NVInfoPtr;
err :LONGINT;
BEGIN
IF nv.base=NIL THEN
d.PrintF("No nonvolatile.library!\n");
HALT(20);
END;
args := d.ReadArgs(template, argv, NIL);
IF args=NIL THEN
IF d.PrintFault(d.IoErr(), "SetNV") THEN END;
HALT(20);
END;
info := nv.GetNVInfo(argv.killReq);
size := str.Length(argv.data^) DIV 10 + 1;
d.PrintF("Size: %ld\n", size);
IF size>info.maxStorage THEN
d.PrintF("String too long (or NVRAM too small :)\n");
HALT(20);
END;
err := nv.StoreNV(argv.appName^, argv.itemName^, y.VAL(nv.DataPtr, argv.data), size, argv.killReq);
CASE err OF
0:
|nv.errBadName:
d.PrintF("App or itemname is illegal\n");
HALT(20);
|nv.errWriteProt:
d.PrintF("NVRAM is write protected!\n");
HALT(20);
|nv.errFail:
d.PrintF("NVRAM is full or write protected!\n");
HALT(20);
|nv.errFatal:
d.PrintF("FATAL Error!\nPossible loss of data.");
HALT(20);
END;
CLOSE
d.FreeArgs(args);
nv.FreeNVData(y.VAL(nv.DataPtr, info));
END SetNV.